//
//  RXXKMainViewController.m
//  RXXKVideo
//
//  Created by 星仔 on 2019/3/17.
//  Copyright © 2019年 rxx. All rights reserved.
//

#import "RXXKMainViewController.h"
#import "RXXKPlayViewController.h"
#import "RXXKOtherViewController.h"
#import "UIImage+RXCategory.h"
#import "const.h"

@interface RXXKMainViewController ()


@end

@implementation RXXKMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.backgroundImage = [UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(RX_SCREEN_WIDTH, RX_TABBAR_HEIGHT)];
    self.tabBar.shadowImage = [UIImage new];
    
    [self setupChildVC:[RXXKPlayViewController new] title:@"首页"];
    [self setupChildVC:[RXXKOtherViewController new] title:@"关注"];
    [self setupChildVC:[RXXKOtherViewController new] title:@"消息"];
    [self setupChildVC:[RXXKOtherViewController new] title:@"我的"];
}
- (void)setupChildVC:(UIViewController *)vc title:(NSString *)title{
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [[UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(36, 3)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = [[UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(36, 3)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //这两个方法的使用及作用
    vc.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -16);
    vc.tabBarItem.imageInsets = UIEdgeInsetsMake(26, 0, -26,0);
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithWhite:1.0 alpha:0.6],NSFontAttributeName:[UIFont systemFontOfSize:16.0]} forState:UIControlStateNormal];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:16.0]}  forState:UIControlStateSelected];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}

@end
